home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11047 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ctsc.hkbc.hk!not-for-mail
  2. From: c2155197@Comp.HKBU.Edu.HK (Lin Pang Kui Michael)
  3. Newsgroups: comp.lang.c
  4. Subject: Help!READ() in UNIX socket
  5. Date: 21 Mar 1996 16:50:06 GMT
  6. Organization: Hong Kong Baptist University
  7. Message-ID: <4is1bu$1aat@ctsc.hkbc.hk>
  8. NNTP-Posting-Host: pistis.comp.hkbu.edu.hk
  9. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  10.  
  11. hi all,
  12.     i m currently writing a client server application in Linux. Part of my
  13. server program is shown as below :
  14. __________________________________________________________________________
  15.         :
  16.         :
  17.     n = read(sockfd,buff,BUFFSIZE);
  18.     if (n == 0) return
  19.     else if (n <0) {
  20.         printf("error.....");
  21.         close_socket(sockfd);
  22.         :
  23.         :
  24. ---------------------------------------------------------------------------
  25.     My server program works well except that when the client program
  26. suddenly "die" (e.g. break by CTRL-C).
  27.        When the read() returns -1 , my server program will print the "error.."
  28. message and then it will be terminated by sth like "segment
  29. fault"!! How can I trap this system call error so that my server program 
  30. could run continuously ??
  31.  
  32.  
  33. Thanks in advance !!
  34.  
  35. Michael
  36.  
  37.